#include "Camera.h" 
#include "Global.h"

Camera::Camera(int& persoX, int& persoY, int persoW, int persoH): 
persoX(persoX)  , persoY(persoY) , persoW(persoW) , persoH(persoH),
tailleMondeW(0) , tailleMondeH(0)
{}

void Camera::getPosCamera(int& x, int& y) {
	x =  persoX - (TRAVAIL_WIDTH - persoW) / 2;
	y =  persoY - (TRAVAIL_HEIGHT - persoH) / 2;

	if ( x < 0 ) x = 0;
	
	if ( y < 0 ) y = 0;
	
	if ( x + TRAVAIL_WIDTH > tailleMondeW )
		x = tailleMondeW - TRAVAIL_WIDTH;
	
	if ( y + TRAVAIL_HEIGHT > tailleMondeH )
		y = tailleMondeH - TRAVAIL_HEIGHT;
}

void Camera::setTarget(int& x, int& y, int w, int h) {
	persoX = x;
	persoY = y;
	persoW = w;
	persoH = h;
}

void Camera::setTailleMonde(int w, int h) {
	tailleMondeW = w;
	tailleMondeH = h;
}

Camera::~Camera() {}